#include <stdio.h>
#include "GlobalMessage.h"
#include <string.h>
#include <stdlib.h>

CInfo *CreateCInfo(const char *name, int sock)
{
    CInfo * c = (CInfo *)malloc(sizeof(CInfo));// 在堆上创建结构体
    if (c == NULL)
    {
        return NULL;
    }

    strcpy(c->ClientName, name);
    c->sock = sock;

    return c;
}

// 打印
void PrintCInfo(void *p)
{
    CInfo *c = (CInfo *)p;
    printf("用户名：%s  套接字：%d\n", c->ClientName, c->sock);
}

bool IsClientNameEqual(void *clientPtr, void *clientName)
{
    CInfo *c = (CInfo *)clientPtr;
    char * CName = (char *)clientName;

    return strcmp(c->ClientName, CName) == 0;
}

bool IsClientSockEqual(void *ClientPtr, void *sock)
{
    CInfo *c = (CInfo *)ClientPtr;
    int s = (int)sock;

    return c->sock == s;
}
